package com.kanche.bigbaby.collection;

import android.content.res.TypedArray;

import com.kanche.bigbaby.R;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

//import com.kkche.bss.R;

/**
 * Created by nealmi on 6/11/14.
 */
public final class CollectionUtils {
    private CollectionUtils() {
    }
//    public static Map<String, String> toMap(String[] keys, TypedArray values) {
//        Map<String, String> itemMapping = new HashMap<String, String>();
//        int len = keys.length;
//        for (int i = 0; i < len; i++) {
//            itemMapping.put(keys[i], String.valueOf(values.getResourceId(i, R.drawable.icon_kanche)));
//        }
//        return itemMapping;
//    }

    public static List<Map<String, String>> toMapList(String[] keys, String[] labels) {
        List<Map<String, String>> list = new ArrayList<Map<String, String>>();

        int len = keys.length;
        for (int i = 0; i < len; i++) {
            Map<String, String> item = new HashMap<String, String>();
            item.put("key", keys[i]);
            item.put("label", labels[i]);
            list.add(item);
        }
        return list;
    }
    public static List<Map<String, String>> toMapList(String[] keys, String[] labels, TypedArray icons) {
        List<Map<String, String>> list = new ArrayList<Map<String, String>>();

        int len = keys.length;
        for (int i = 0; i < len; i++) {
            Map<String, String> item = new HashMap<String, String>();
            item.put("key", keys[i]);
            item.put("label", labels[i]);
            item.put("icon", String.valueOf(icons.getResourceId(i, R.drawable.icon_other)));
            list.add(item);
        }
        return list;
    }
    public static Map<String, String> toMap(String[] keys, String[] values) {
        Map<String, String> itemMapping = new HashMap<String, String>();
        int len = keys.length;
        for (int i = 0; i < len; i++) {
            itemMapping.put(keys[i], values[i]);
        }
        return itemMapping;
    }

    public static Set<Integer> toSet(int[] availableMenusIndex) {
        Set<Integer> set = new HashSet<Integer>();
        for (int i : availableMenusIndex) {
            set.add(i);
        }
        return set;
    }
}
